﻿@using Kojarskiy.Core
@using Kojarskiy.Models
@model Kojarskiy.Models.SiteMap

@{
    var context = new KojarskiyDbEntities();
    var slides =  context.Gallery.Where(x => x.SiteMapId == 1).ToList();    
}

@section AdditionalScripts
{
    <script type="text/javascript">
        var currentSlide = 0;
        var slideCount = 0;
        var currentUrl = "";

        $(document).ready(function () {
            currentUrl = $("#bgSlider").data("firstslide");
            $('#menuslider').bxSlider(
                {
                    auto: true,
                    pagerCustom: '#menupagerslider',
                    onSlideAfter: function ($slideElement, oldIndex, newIndex) {
                        currentSlide += 1;
                        currentUrl = $slideElement.data("url");
                        slideCount = $("#bgSlider").data("count");
                    }
                });
        })
    </script>
}

@section Slider
{

    <div id="welcome_wrapper">
        <div id="welcome">
            <div id="gallery">
                
                <img id = "bgSlider" src="@Url.Content("~/Content/images/left-gradient.png")" data-count="@slides.Count" 
                class="gradient"></img>


                <ul id="menuslider" class="menuslider">
                    @foreach (var image in slides)
                    {
                        <li data-url="@image.Url"><a href="@Url.Content(image.Url)">
                                                      <div class="slider-text">@Localization.GetLocalizedValue(image.LocalizationKey)</div>
                                                      <img src="@Url.Content(image.Path)"/>
                                                  </a></li>
                    }
                </ul>
                
                <div id="menupagerslider">
                    @{
                        int i = 0;
                        foreach (var image in slides)
                        {	                
                            <a data-slide-index="@i" href="">@image.Description</a>
                            i++;
                        }
                    }
                </div>
            </div>
        </div>
    </div>

<div id="catalog-wrapper">
    <div id="catalog">
        @{
            switch (Localization.Current)
            {
                case "ru":
                    @Html.Partial("_Catalog", context.SiteMap.Where(x => x.ParentId != null && x.ParentId == 4 && x.Culture == Localization.Current).ToList())
                    break;
                case "en":
                    @Html.Partial("_Catalog", context.SiteMap.Where(x => x.ParentId != null && x.ParentId == 163 && x.Culture == Localization.Current).ToList())
                    break;
                case "ua":
                    @Html.Partial("_Catalog", context.SiteMap.Where(x => x.ParentId != null && x.ParentId == 169 && x.Culture == Localization.Current).ToList())
                    break;
                case "de":
                @Html.Partial("_Catalog", context.SiteMap.Where(x => x.ParentId != null && x.ParentId == 230 && x.Culture == Localization.Current).ToList())
                    break;
            }
}
    </div>
</div>

}

<div style="clear: both;"></div>

@if(User.IsInRole("Administrators"))
{
<div class="form-group f_r">
    <button type="button" onclick="location.href='@Url.Action("Edit", "SiteMap", new { id = Model.SiteMapId, returnUrl = Request.RawUrl })'" 
        class="btn btn-sm btn-warning">Редактировать страницу</button>
</div>
}

<div id="content">
    <div class="table">
        <div class="row">
            <div class="col-xs-8">
                @*<div class="well">
                    <h3 class="text-center">@Html.ActionLink("Регистрация авторского права онлайн", "Index","OnlineRegistration")</h3>
                </div>*@

                @Html.Raw(Model.Content)
            
            </div>
            <div class="col-xs-4" style="background: #EDEDED">
                <h3 style="border-bottom: 1px solid gray; padding: 5px 0px 0px 0px">@Localization.GetLocalizedValue("NEWS")</h3>
                @Html.Partial("_News", 3)
            </div>
        </div>
    </div>
</div>